
def get_breadcrumb(cat):
    breadcrumb = {
        "cat1": "",
        "cat2": "",
        "cat3": ""
    }
    if cat.parent is None:
        # 分类没有父分类，肯定是一级分类
        breadcrumb['cat1'] = cat
    elif cat.subs.count() == 0:
        # 没有子分类类，就肯定是三级分类
        breadcrumb['cat3'] = cat
        breadcrumb['cat2'] = cat.parent
        breadcrumb['cat1'] = cat.parent.parent
    else:
        breadcrumb['cat2'] = cat
        breadcrumb['cat1'] = cat.parent

    return breadcrumb